package com.hyz.utils;

import com.hyz.model.asset.Asset;
import com.hyz.model.asset.AssetClasses;
import com.hyz.model.asset.AssetStatus;
import com.hyz.model.asset.UploadAsset;
import org.springframework.stereotype.Component;

import java.sql.Date;

/**
 * @author HGD
 * @date 2022/10/21 8:34
 */
@Component
public class Conversion {
    public Asset getAsset(UploadAsset uploadAsset) {
        Asset asset = new Asset();
        asset.setAssetId(String.valueOf(uploadAsset.getAssetId()));
        asset.setAssetName(uploadAsset.getAssetName());
        asset.setSupplier(uploadAsset.getSupplier());
        asset.setLife((new Date(uploadAsset.getLife().getTime())));
        switch (uploadAsset.getClasses()) {
            case "硬件资产":
                asset.setClasses(AssetClasses.HARDWARE_ASSET);
                break;
            case "软件资产":
                asset.setClasses(AssetClasses.SOFTWARE_ASSET);
                break;
            case "虚拟资产":
                asset.setClasses(AssetClasses.VIRTUAL_ASSET);
                break;
            default:
        }
        asset.setStatus(AssetStatus.UNASSIGNED);
        return asset;
    }
}
